package com.iqiju.guagua.redtone.video.controller;


import com.iqiju.guagua.redtone.video.common.Results;
import com.iqiju.guagua.redtone.video.service.WxRedtoneVideoTypeService;
import com.iqiju.guagua.redtone.video.vo.VideoListFirstVO;
import com.iqiju.guagua.redtone.video.vo.VideoViewVO;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Api(tags = "视频接口")
@RequestMapping("/wx/redtone/video")
public class VideoController {

    @Autowired
    private WxRedtoneVideoTypeService wxRedtoneVideoTypeService;

    @ApiImplicitParams({
            @ApiImplicitParam(name = "wxMiniAppId",value = "小程序自定义ID",required = true,dataType = "String",paramType = "query",example = "1201756694072651777"),
            @ApiImplicitParam(name = "type",value = "视频类型（不写默认第一个类型）",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "searchId",value = "查询id（查询第1页不用传此参数，2345页必须传）",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "num",value = "页码（查询第1页不用传此参数，2345页必须传）",dataType = "String",paramType = "query")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 0, message = "接口返回成功"),
            @ApiResponse(code = 100, message = "参数错误，检查参数是否合法"),
            @ApiResponse(code = 405, message = "token错误"),
            @ApiResponse(code = 401, message = "登录过期或者未登录"),
            @ApiResponse(code = 200, message = "接口返回未知错误，请联系开发人员调试"),
            @ApiResponse(code = 500, message = "接口返回未知错误，请联系开发人员调试")
    })
    @ApiOperation(value = "视频列表查询", notes = "访问此接口，查询视频类型的第一页视频列表，类型参数不传默认返回类型列表加第一个类型的首页视频列表，" +
            "传类型返回参数类型的第一页视频列表，每个类型最多查询5页，查询2345页必须携带类型和查询id")
    @GetMapping("list")
    public Results<VideoListFirstVO> selectPage(@RequestParam(required = false) String wxMiniAppId,
                                          @RequestParam(required = false) String type,
                                          @RequestParam(required = false) String searchId,
                                          @RequestParam(required = false) String num){
        log.info("访问 视频列表查询 接口---------------------------------------------");
        return wxRedtoneVideoTypeService.selectPage(wxMiniAppId,type,searchId,num);
    }



    @ApiImplicitParams({
            @ApiImplicitParam(name = "wxMiniAppId",value = "小程序自定义ID",required = true,dataType = "String",paramType = "query",example = "1201756694072651777")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 0, message = "接口返回成功"),
            @ApiResponse(code = 100, message = "参数错误，检查参数是否合法"),
            @ApiResponse(code = 405, message = "token错误"),
            @ApiResponse(code = 401, message = "登录过期或者未登录"),
            @ApiResponse(code = 200, message = "接口返回未知错误，请联系开发人员调试"),
            @ApiResponse(code = 500, message = "接口返回未知错误，请联系开发人员调试")
    })
    @ApiOperation(value = "视频播放查询", notes = "访问此接口，查询视频播放页面所有内容")
    @GetMapping("view")
    public Results<VideoViewVO> view(@RequestParam(required = false) String wxMiniAppId){
        log.info("访问 视频播放查询 接口---------------------------------------------");
        return wxRedtoneVideoTypeService.view(wxMiniAppId);
    }

}
